<div>
  <h2 mat-dialog-title>API REST</h2>
  <mat-dialog-content>
    <label class="label">Sessions</label>
    <div>
      <button mat-button id="get-session-btn" (click)="fetchActiveConnections()">Fetch</button>
      <button mat-button id="list-sessions-btn" (click)="fetchActiveSessions()">Fetch all</button>
      <button mat-button id="close-session-btn" (click)="closeSession()">Close this session</button>
      <mat-divider></mat-divider>
    </div>

    <label class="label">Connections/Streams</label>
    <mat-form-field class="inner-text-input" [style.fontSize.px]=14>
      <input matInput id="connection-id-field" placeholder="connectionId" [(ngModel)]="connectionId">
    </mat-form-field>
    <mat-form-field class="inner-text-input" [style.fontSize.px]=14>
      <input matInput id="stream-id-field" placeholder="streamId" [(ngModel)]="streamId">
    </mat-form-field>
    <div style="margin-left:9px">
      <mat-checkbox class="checkbox-form" [(ngModel)]="connectionProperties.record" id="record-checkbox">Record
      </mat-checkbox>
      <mat-form-field class="inner-text-input" [style.fontSize.px]=14 style="width:33%">
        <mat-select [(ngModel)]="connectionProperties.role" id="token-role-select">
          <mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator">
            <span [attr.id]="'option-' + enumerator">{{ enumerator }}</span>
          </mat-option>
        </mat-select>
      </mat-form-field>
      <mat-form-field class="inner-text-input" [style.fontSize.px]=14 style="width:40%">
        <input matInput id="connection-data-field" placeholder="data" [(ngModel)]="connectionProperties.data">
      </mat-form-field>
    </div>
    <div>
      <button mat-button id="crate-connection-api-btn" (click)="createConnection()">Create connection</button>
      <button mat-button id="update-connection-api-btn" (click)="updateConnection()" [disabled]="!connectionId">Update
        connection</button>
      <button mat-button id="force-disconnect-api-btn" (click)="forceDisconnect()"
        [disabled]="!connectionId">Disconnect</button>
      <button mat-button id="force-unpublish-api-btn" (click)="forceUnpublish()"
        [disabled]="!streamId">Unpublish</button>
      <mat-divider></mat-divider>
    </div>

    <label class="label">Recordings</label>
    <div>
      <button mat-button id="list-recording-btn" (click)="listRecordings()">List recordings</button>
      <button mat-button id="start-recording-btn" (click)="startRecording()">Start recording</button>
      <button id="rec-properties-btn" mat-icon-button style="width: 24px; height: 24px; line-height: 24px;"
        title="Recording properties" (click)="toggleRecProperties()">
        <mat-icon style="font-size: 18px; line-height: 18px; width: 18px; height: 18px"
          aria-label="Recording properties">
          {{recPropertiesIcon}}</mat-icon>
      </button>
      <app-recording-properties *ngIf="showRecProperties" [(recordingProperties)]="recordingProperties">
      </app-recording-properties>
    </div>
    <div>
      <mat-form-field class="inner-text-input" [style.fontSize.px]=14>
        <input matInput id="recording-id-field" placeholder="recordingId" [(ngModel)]="recordingId">
      </mat-form-field>
      <button mat-button id="stop-recording-btn" (click)="stopRecording()" [disabled]="!recordingId">Stop
        recording</button>
      <button mat-button id="get-recording-btn" (click)="getRecording()" [disabled]="!recordingId">Get
        recording</button>
      <button mat-button id="delete-recording-btn" (click)="deleteRecording()" [disabled]="!recordingId">Delete
        recording</button>
    </div>
    <mat-form-field *ngIf="!!response" id="response-text-area" appearance="fill">
      <textarea id="api-response-text-area" [(ngModel)]="response" matInput readonly></textarea>
    </mat-form-field>
  </mat-dialog-content>
  <mat-dialog-actions>
    <button mat-button id="close-dialog-btn"
      [mat-dialog-close]="{session: session, recordingProperties: recordingProperties}">CLOSE</button>
  </mat-dialog-actions>
</div>
